package start;
import tool.s;
public class T209 {
    public static void main(String[] args) {
        int []nums ={2,3,1,2,4,3};
        int r=minSubArrayLen(7,nums);
//        s.print(nums);
        System.out.println(r);

    }
    public static int minSubArrayLen(int target, int[] nums) {
        if(nums[0]>target){
            return 1;
        }
        int left=0;
        int right=1;
        int sum=nums[0];
        int r=0;
        while(right<=nums.length){
            if(sum<target){
                if(right!=nums.length){
                    sum+=nums[right++];
                }else {
                    break;
                }

            }else {
                if(r>(right-left)||r==0){
                    r=right-left;
                }
                sum-=nums[left++];
            }
        }
        return r;




    }
}
